import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ShopVO, ShopForm, ShopQuery } from '@/api/retail/shop/types';

/**
 * 查询商铺信息列表
 * @param query
 * @returns {*}
 */

export const listShop = (query?: ShopQuery): AxiosPromise<ShopVO[]> => {
  return request({
    url: '/retail/shop/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询商铺信息详细
 * @param id
 */
export const getShop = (id: string | number): AxiosPromise<ShopVO> => {
  return request({
    url: '/retail/shop/' + id,
    method: 'get'
  });
};

/**
 * 新增商铺信息
 * @param data
 */
export const addShop = (data: ShopForm) => {
  return request({
    url: '/retail/shop',
    method: 'post',
    data: data
  });
};

/**
 * 修改商铺信息
 * @param data
 */
export const updateShop = (data: ShopForm) => {
  return request({
    url: '/retail/shop',
    method: 'put',
    data: data
  });
};

/**
 * 店铺电子账户信息
 * @param id
 */
export const getAccountList = (id: string | number | Array<string | number>) => {
  return request({
    url: '/retail/shop/accounts/' + id,
    method: 'get'
  });
};

export const changeShopWeight = (id: string | number, weight: string | number) => {
  return request({
    url: '/retail/shop/weight/' + id + "/" + weight,
    method: 'get'
  });
}

export const clearGoogleAuth = (id: string | number) => {
  return request({
    url: '/retail/shop/clearGoogleAuth/' + id,
    method: 'get'
  });
}
